<?php
namespace Api\Controller;
use Common\Controller\ApiController;
use Common\ORG\PublicFunction;
use Common\ORG\WxFunction;
use Think\Db;


/**

 * 分类

 *

 * 所有分类接口。

 * @Author      LD(191696242@qq.com)

 * @Version     1.o

 * @Date        2020/12/23

 * @Time        16:00

 * @since

 */
class CategoryController extends ApiController{

    public function _initialize()
    {
        parent::_initialize();
        if(!IS_POST){
            $this->ajaxReturn(1, '提交方式错误！');
        }
    }


    /**
     * getArea
     * 地区

     * 获取地区

     * @access public

     * @param int $pid (必填：否) 登陆注册等

     * @since

     * @return json

     */
    public function getArea(){

        $pid   = I('post.pid', 0, 'intval');  //父级ID
        $area  = D('CategoryDistrict')->get_city_and_children($pid);
        $this->ajaxReturn(0, 'ok', $area);

    }

    /**
     * 单一分类合集
     * @param string $type (必填：是) 分类类型QS_wage
     */
    public function single(){
        $type   = I('post.type', '', 'trim,badword');
        if(empty($type)){
            $this->ajaxReturn(1, '分类类型不能为空！');
        }
        $category = D('Category')->get_category_cache();
        if(empty($category[$type])){
            $this->ajaxReturn(1, '分类类型不存在！');
        }

        $this->ajaxReturn(0, 'ok', $category[$type]);
    }

    /**
     * 职位分类
     * @param
     */
    public function positionType(){

        $category = D('CategoryJobs')->get_all_cate();
        $this->ajaxReturn(0, 'ok', $category);
    }

    /**
     * 工程分类
     * @param
     */
    public function engineeringType(){

        $category = D('CategoryMajor')->get_engineering_and_children();
        $this->ajaxReturn(0, 'ok', $category);
    }


}
?>